<template>
  <!-- 底部部分 => list有数据的时候，才展示  list.length > 0 -->
  <footer  class="footer" v-if="list.length > 0">
    <span class="todo-count"><strong>{{num}}</strong>剩余</span>
    <ul class="filters">
      <li>
        <a  href="#/" :class="{selected:stud==='all'}" @click="$emit('stud-all','all')">全部</a>
      </li>
      <li>
        <a  href="#/active" :class="{selected:stud==='undone'}" @click="$emit('stud-all','aundone')">进行中</a>
      </li>
      <li>
        <a  href="#/completed" :class="{selected:stud==='done'}" @click="$emit('stud-all','done')">已完成</a>
      </li>
    </ul>
    <!-- 有已完成的任务，才需要显示这个按钮 -->
    <button @click="$emit('remove-event')" class="clear-completed">清除已完成</button>
  </footer>
</template>

<script>
export default {
  //接收
  props:{
    list:{
      type:Array,
      required:true
    },
    stud:{
      type:String,
      required:true,
      // JY
      Validator(value){
        return ['all','done','undone'].includes(value)
      }
    }
  },
  // 剩余未完成数量
  computed:{
    num(){
      // false 未完成的长度
      return this.list.filter(item=>item.done===false).length
    }
  }
};
</script>

<style></style>
